import JSEncrypt from 'jsencrypt/bin/jsencrypt.min'

// 密钥对生成 http://web.chacuo.net/netrsakeypair

const publicKey = 'MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAqi95I7bXvosAE9k5mWC1uRspOj/K9hAjZLOZKL/' +
  'UCjpeZ9J3SW8pcbX1toETjXX/9INlAJhiNitLanMQXjWgCirg0o0lHTOQgjk9zjSSA2IdZxS7WP4cGky2A/fMpIyZl2ouG2UxyIb/' +
  'cVvIn8TYK+l3lqXIQmGENIYxQUOwYWY4BhbzmISa9EaaZNPBP0y0KAMcon0osCjyih3z6riD8zYJzLEtcFKcHRou5b2VHZtMRi+v6tQo9PjhqS3+TK5h9xragnms3eViIfkYW0dDh1DosE85/' +
  'gEYJIq0tL4QyaLZDp0mWGsG4rO8O0W1a4Bu8rhTBhlPd3jx6UBVPvNEjwIDAQAB'

const privateKey = ''
// 加密
export function encrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPublicKey(publicKey) // 设置公钥
  return encryptor.encrypt(txt) // 对数据进行加密
}

// 解密
export function decrypt(txt) {
  const encryptor = new JSEncrypt()
  encryptor.setPrivateKey(privateKey) // 设置私钥
  return encryptor.decrypt(txt) // 对数据进行解密
}

